PROCEDURE TForm4.TestShlWAPISHMessageBoxCheck(Sender : TObject);
//Existence as ordinal 185 tested and confirmed under
//Windows 2003 (with SP 2)
VAR wndhandle : HWND;
VAR messagetext : STRING;
VAR wcharmsgtxt : WideString;
VAR msgboxtitle : STRING;
VAR wchardlgtitle : WideString;
VAR msgboxtype : UINT;
VAR defretval : INTEGER;
VAR registryvalstr : STRING;
VAR wcharregvalstr : WideString;
VAR apiretval : INTEGER;
VAR newinfoline : STRING;
BEGIN
wndhandle := 0;
messagetext := '';
wcharmsgtxt := '';
msgboxtitle := '';
wchardlgtitle := '';
msgboxtype := 0;
defretval := 0;
registryvalstr := '';
wcharregvalstr := '';
apiretval := 0;
newinfoline := '';
wndhandle := Handle;
messagetext := 'Hello World !' + #13 + #10 +
'ShlWAPI function test completed.';
//Under Windows 2003 and later, it is not necessary to
//append a question such as the following to the message box's text,
//a text to the same effect is already added to the dialog by Windows
//" + #13 + #10 + 'Always show this message ?';"
msgboxtitle := 'SHMessageBoxCheck Test';
//The following line sets the "Ok" button as the default button
//(i.e. the question "In the future, do not show me this dialog box"
//is answered with "Ok" if the user closes the dialog by pressing Enter/Return).
//However, only the state of the check box has any influence on whether the
//the dialog is shown again or not.
//To return to the initial behaviour of the app, set the string in the
//registry value "TestShlWAPIFunctions3{9F430225-F4CB-4A7E-B717-0C118D8FAC69}", under
//"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain"
//to "YES", or simply delete the value.
msgboxtype := MB_OKCANCEL OR MB_DEFBUTTON1 OR MB_ICONINFORMATION;
defretval := $FFFF;
registryvalstr := 'TestShlWAPIFunctions3' + '{9F430225-F4CB-4A7E-B717-0C118D8FAC69}';
apiretval := SHMessageBoxCheck(wndhandle, PChar(messagetext), PChar(msgboxtitle),
msgboxtype, defretval, PChar(registryvalstr));
newinfoline := 'SHMessageBoxCheck returned ' + IntToStr(apiretval) + ' (0x' + IntToHex(apiretval, 8) + ')';
Memo1.Lines.Add(newinfoline);
msgboxtype := MB_ABORTRETRYIGNORE OR MB_DEFBUTTON3 OR MB_ICONERROR;
//Combine bit 29, indicating a non-system (i.e. app) specific error with
//an arbitrary, unique value, specific to this particular dialog or class/group of dialogs.
defretval := $20000000 OR $8080;
//messagetext := 'Tests the veracity of the Microsoft doc. on this function !' + #13 + #10 +
//'This message box should be ignored.';
wcharmsgtxt := 'If this message is displayed, SHMessageBoxCheckW is exported as ordinal 191.' + #13 + #10 +
'This message box should be ignored.';
wchardlgtitle := msgboxtitle;
//registryvalstr := 'TestShlWAPIFunctions3' + '{81EE5244-6596-4154-BCCB-6F6E6970A7F0}';
wcharregvalstr := 'TestShlWAPIFunctions3' + '{81EE5244-6596-4154-BCCB-6F6E6970A7F0}';
//apiretval := SHMessageBoxCheck(wndhandle, PChar(messagetext), PChar(msgboxtitle),
// msgboxtype, defretval, PChar(registryvalstr));
apiretval := SHMessageBoxCheckW(wndhandle, PWChar(wcharmsgtxt), PWChar(wchardlgtitle),
msgboxtype, defretval, PWChar(wcharregvalstr));
newinfoline := 'SHMessageBoxCheck returned ' + IntToStr(apiretval) + ' (0x' + IntToHex(apiretval, 8) + ')';
Memo1.Lines.Add(newinfoline);
Memo1.Lines.Add('');
END; |